#ifndef RENDERABLE_H
#define RENDERABLE_H

#include <d3dx11effect.h>
#include <d3d11.h>
#include <vector>

//#define PIX


typedef unsigned int uint;

class Renderable
{

	public:	
		Renderable();
		virtual ~Renderable();

		void createEffect(const char* filename, ID3D11Device* _dxDev, ID3DX11Effect** fx);
		void createEffect(const char* filename, ID3D11Device* _dxDev);
		bool loadEffect(const char* filename, std::vector<char> &compiledShader) const;
		virtual void Update(float dt)=0;
	
		ID3DX11Effect*				getFX() const { return _fx; }

		HRESULT createInputLayout(ID3D11Device* g_dev, const D3D11_INPUT_ELEMENT_DESC* elem_desc, unsigned int num_elements, const void* input_signature, SIZE_T length);


		static bool createBuffer(ID3D11Device* g_dev, ID3D11Buffer** buffer,   unsigned int size, D3D11_USAGE usage_flags,
								 unsigned int bind_flags, unsigned int cpu_flags,
								 unsigned int misc_flags, unsigned int structuredByteStride, const void* initial_data,
								 unsigned int sysMemPitch, unsigned int sysMemSlicePitch);
		
		static bool createVertexBuffer(ID3D11Device* g_dev, ID3D11Buffer** buffer,   unsigned int size, D3D11_USAGE usage_flags,
								 bool bstreamOut, unsigned int cpu_flags, const void* initial_data=0);



		ID3D11InputLayout* getInputLayout() { return _IA; }



		static bool createTexture2D(ID3D11Device* g_dev, ID3D11Texture2D** tex, uint width,
							uint height, DXGI_FORMAT format, uint bind_flags, uint arraySize, 
							D3D11_USAGE usage_flags=D3D11_USAGE_DEFAULT, uint cpu_flags=0, 
							uint misc_flags=0, uint mipLevels=1, uint quality=0, uint count=1);


//_________________________

		static bool createTexture2D_SRV(ID3D11Device* g_dev, ID3D11Resource* res, 
								ID3D11ShaderResourceView** srv, DXGI_FORMAT format,
								uint mostDetailedMip,
								uint mipLevels);

		static bool createTexture2DArray_SRV(ID3D11Device* g_dev, ID3D11Resource* res, 
									ID3D11ShaderResourceView** srv, DXGI_FORMAT format,
									uint mostDetailedMip, 
									uint mipLevels, uint firstArraySlice, 
									uint arraySize);

//_________________________

		static bool createTexture2D_RTV(ID3D11Device* g_dev, ID3D11Resource* res, 
								ID3D11RenderTargetView** rtv, DXGI_FORMAT format,
								uint mipSlice);

		static bool createTexture2DArray_RTV(ID3D11Device* g_dev, ID3D11Resource* res, 
									ID3D11RenderTargetView** srv, DXGI_FORMAT format,
									uint mostDetailedMip, 
									uint mipLevels, 
									uint arraySize);



	private:
		ID3DX11Effect*		_fx;
		ID3D11InputLayout*	_IA;
		
		

	

};



#endif





